/**
 * @param {number[]} nums
 * @return {number}
 */
var wiggleMaxLength = function (nums) {
    let len = nums.length, max = 1,curr=0,pre=0
    if (len < 2) return len
    for (let i = 0; i < len - 1; i++) {
        curr =  nums[i+1] - nums[i]
        if((curr>0&&pre<=0)||(curr<0&&pre>=0)){
            max++
            pre=curr
        }
    }
    return max
};
console.log(wiggleMaxLength([102,101,20,91,156,78,75,142,69,81,46,142,113,163,190,178,13,36,134,54]));